#ifndef Vertex3d_H
#define Vertex3d_H

#include <GL\GLee.h>
#include <QtOpenGL/QtOpenGL>
#include <gl/glu.h>
#include <QList>

#define PI 3.1415926535897932384626433832795
#define PIdiv180 (PI/180.0)
#define ZeroDistance 0.0f

enum MovingPlane
{
	XYPlane,
	XZPlane,
	YZPlane
};

struct Color4b
{
	unsigned char R, G, B, A;

	Color4b(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
	{
		this->R = r;
		this->G = g;
		this->B = b;
		this->A = a;
	}

	Color4b(Color4b *color)
	{
		this->R = color->R;
		this->G = color->G;
		this->B = color->B;
		this->A = color->A;
	}
};

class Vertex3f
{
public:
	Vertex3f(float X, float Y, float Z);
	Vertex3f(Vertex3f *vertex);
	~Vertex3f();

	Vertex3f* GetNearestNeighbor(Vertex3f *targetVertex);

	//coloring and rendering
	void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
	void SetColor(Color4b *color);
	void RenderVertexColorCheck(Color4b *color);
	void RenderVertexNoColorCheck(Color4b *color);

	//math functions
	float GetEuclideanDistance(const Vertex3f *vertex) const;
	float GetProjectionLength(Vertex3f *directionVectorStart, Vertex3f *directionVector) const;

	Vertex3f* Sum(Vertex3f *u) const;
	Vertex3f* Difference (Vertex3f*) const;
	void Add(Vertex3f *u);
	void Subtract(Vertex3f *u);

	float Vertex3f::GetLength() const;
	void Normalize();
	Vertex3f* Multpli(float value) const;
	Vertex3f* CrossProduct(Vertex3f * u) const;
	float DotProduct(Vertex3f *u) const;

	//vars
	float X, Y, Z;
	Color4b *Color;
	QList<Vertex3f*> *neighbors;
	bool IsColored;
};

#endif // MESH_H